<template>
  <el-aside width="200px">
    <el-row class="tac">
      <el-col>
        <el-menu
          default-active="1"
          class="el-menu-vertical-demo"
          @open="handleOpen"
          @close="handleClose"
        >
          <el-menu-item index="1" @click="goPage('addcourse')">
            <template #title>
              <i class="el-icon-reading"></i>
              <span slot="title">课程发布</span>
            </template>
          </el-menu-item>

          <el-menu-item index="2" @click="goPage('mangecourse')">
            <template #title>
              <i class="el-icon-edit"></i>
              <span slot="title">课程管理</span>
            </template>
          </el-menu-item>

          <el-menu-item index="3" @click="goPage('salespreview')">
            <template #title>
              <i class="el-icon-data-line"></i>
              <span slot="title">销售预览</span>
            </template>
          </el-menu-item>

          <el-menu-item index="4" @click="goPage('manageaccount')">
            <template #title>
            <i class="el-icon-user"></i>
            <span slot="title">账户管理</span>
          </template>
          </el-menu-item>
        </el-menu>
      </el-col>
    </el-row>
  </el-aside>
</template>

<script>
  var $this = {};
  export default {
    data() {
      return {};
    },
    beforeCreate() {
      $this = this;
    },
    methods: {
      handleOpen(key, keyPath) {
        console.log(key, keyPath);
      },
      handleClose(key, keyPath) {
        console.log(key, keyPath);
      },

      goPage(link) {
        if (link === "addcourse") {
          $this.$router.push("/addcourse").catch(error => error);
        } else if ((link === "mangecourse")) {
          $this.$router.push("/mangecourse").catch(error => error);
        } else if ((link === "salespreview")) {
          $this.$router.push("/salespreview").catch(error => error);
        }else if ((link === "manageaccount")) {
          $this.$router.push("/manageaccount").catch(error => error);
        }
      }
    }
  };
</script>

<style scoped>
  .el-row{
    height: 100%;
  }

  .el-menu{
    border-right:none;
    margin-top: 30px;
    margin-bottom: 30px;
    min-width: 200px;
  }
  .el-aside{
    border-right: 1px solid #f5f1f1;
  }
</style>
